<script>
import { wechat } from "./http/api";
import { setToken } from "./http/http";

export default {
    globalData: {
        /**
         * @type {Uniapp.UniApp.GetSystemInfoResult}
         */
        systemInfo: null,
        version: "1.0.10", //每次升级需要修改
        appName: "sea",
    },
    methods: {
        wechatLogin() {
            return new Promise((resolve, reject) => {
                uni.login({
                    async success(r) {
                        let res = await wechat({
                            code: r.code,
                        });
                        let mp_token = res.Token;
                        setToken(mp_token);
                        resolve();
                    },
                });
            });
        },
        systemInfo() {
            let s = this;
            uni.getSystemInfo({
                success: (res) => {
                    console.log("systemInfo:", res);
                    s.globalData.systemInfo = res;
                },
            });
        },
    },
    onLaunch: function () {
        console.log("App Launch");
        this.systemInfo();
    },
    onShow: function () {
        console.log("App Show");
    },
    onHide: function () {
        console.log("App Hide");
    },
};
</script>

<style lang="scss">
/*每个页面公共css */
@import "tailwindcss/base";
@import "tailwindcss/utilities";
@import "./static/animate.min.css";
</style>
